#!/bin/bash

PAGES_BRANCH_NAME=gh-pages
GIT_ROOT_PATH=./aios-guide-book

cd $GIT_ROOT_PATH

echo "git pull"
git pull

echo "gitbook build"
gitbook build

mv ./_book ../

git checkout -B $PAGES_BRANCH_NAME

rm -rf *

cp ../_book/* . -r

git add .

git commit -m "deploy"

git push --set-upstream origin gh-pages -f

rm -rf ../_book

git checkout master
